package com.yls.except.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository(value="imgDao")
public interface ImgDao {

	/**
	 * 新增图片信息
	 * @param map
	 * @return
	 */
	@Insert("insert into yls_image " +
			"(img_type,type_id,img_address,addtime,addip,isdisabled) " +
			"values " +
			"(#{img_type},#{type_id},#{img_address},#{addtime},#{addip}," +
			"#{isdisabled})")
	@Options(useGeneratedKeys = true, keyProperty = "img_id")
	int insertImgInfo(Map<String, Object> map);

	/**
	 * 根据图片类型和类型id获取图片列表信息
	 * @param map
	 * @return
	 */
	@Select("select img_address from yls_image where " +
			"img_type=#{type} and type_id=#{typeid} and isdisabled=1")
	List<Map<String, Object>> selectImgByTypeAndTypeId(Map<String, Object> map);

	/**
	 * 删除认证图片信息
	 * @param map
	 * @return
	 */
	@Delete("delete from yls_image where img_type=#{type} and type_id=#{typeid}")
	int deleteImgByTypeId(Map<String, Object> map);
	/**
	 * 根据图片类型和类型id获取图片列表信息
	 * @param map
	 * @return
	 */
	@Select("select img_address from yls_image where " +
			"img_type=#{type} and isdisabled=1")
	List<Map<String,Object>> selectImgByType(Map<String, Object> map);

	/**
	 * 获取所有图片地址
	 * @return
	 */
	@Select("select img_address from yls_image where isdisabled=1")
    List<Map<String,Object>> selectIMgList();

	/**
	 * 根据图片获取图片地址
	 * @return
	 */
	@Select("select img_address from yls_image where img_type=#{type} and isdisabled=1")
	List<Map<String,Object>> selectImgByTyep(String type);
}
